/**
 * this class contains public members
 */

package pl.ydp.editor.view
{
	public class NoSemicolons
	{
		public var list:Array
		
		public function ViewList()
		{
			list = new Array()
		}
		
		public function addView(view:IView):void
		{
			list.push(view);			
		}
		
		public function removeView(view:IView):void
		{
			var index:int = getViewIndex(view.title);
			
			if(index > -1)
				list.splice(index,1);
		}
		
		public function checkIfExists(view:IView):Boolean
		{
			var exists:Boolean = false;
			var i:int;
			
			for(i = 0; i < list.length; i++)
			{
				if(list[i].title == view.title)
					exists = true
			}
			
			return exists
		}
		
		public function removeBehind(view:IView):void
		{
			var fromIndex:int = getViewIndex(view.title)+1
			var count:int = list.length - fromIndex;
			
			if(fromIndex > -1)
				list.splice(fromIndex,count); 
		}
		
		
		public function getViewIndex(viewTitle:String):int
		{
			var i:int;
			var index:int = -1
			
			for(i = 0; i < list.length; i++)
			{
				if(viewTitle == list[i].title)
				{
					index = i;
				}
			}
			
			return index;
			
			
		}
		
		public function getView(index:int):IView
		{
			return list[index];
		}
		
		
		public function get length():int
		{
			return list.length
		}
		
		
		

	}
}